<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 声明一个空对象 把数组里的每一项 作为对象里的属性， 利用属性名不能重复来 去重

      var arr = [1, 1, "true", "true", true, true, 15, 15, false, false, undefined, undefined, null, null, NaN, NaN, "NaN", 0, 0, "a", "a", {}, {}];

      var obj = {};
      var newArr = [];
      for (var i = 0; i < arr.length; i++) {
        if (!obj[arr[i]]) {
          newArr.push(arr[i]);
          obj[arr[i]] = 1;
        } else {
          obj[arr[i]]++;
        }
      }
      console.log(obj);
      
      console.log(newArr);
      // 0: 1
      // 1: "true"
      // 2: 15
      // 3: false
      // 4: undefined
      // 5: null
      // 6: NaN
      // 7: 0
      // 8: "a"
      // 9: {}

     // 能够去重 NaN 和 { } 但是 布尔值 true 被删掉了
    </script>
  </body>
</html>
